﻿using Carlife.Inf;
using ICarlifeRespository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CarlifeRespository
{
    public class UOfWork : IUOfWork
    {
        private readonly CarlifeDbcontext db;
        private IDbConnection dbs;

        public UOfWork(CarlifeDbcontext db, DapperHelper factory)
        {
            this.db = db;
            dbs = factory.GetDbConnection();
        }

        public CarlifeDbcontext dbcontext()
        {
            return db;
        }

        public IDbConnection GetDbConnection()
        {
            dbs.Open();
            return dbs;
        }

        public int SaveChanges()
        {
            return db.SaveChanges();
        }
    }
}
